<?php
/*
 * @Author       :  　 @祥💥　技术支持
 * @Mail         : shejiz@qq.com
 * @Date         : 2025-06-10 14:15:01
 * @LastEditTime : 2025-06-21 14:34:51
 * @LastEditors  :  　 @祥💥　技术支持
 * @Description  : 
 * @FilePath     : \35dir\snapshot.php
 * It's up to you ^_^
 * Copyright (c) 2025 by shejiz@qq.com, All Rights Reserved. 
 */
header('Content-Type: image/gif');

$save_path = __DIR__ . '/snapshot/';
if (!file_exists($save_path)) {
    mkdir($save_path, 0777, true);
}
$site = $_GET['site'];

if(is_file($save_path. md5($site). '.gif')) {
    readfile($save_path. md5($site). '.gif'); exit;
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://s0.wp.com/mshots/v1/' . $site);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'cache-control: no-cache',
    'pragma: no-cache',
    'priority: u=0, i',
    'referer: http://dh.wanwanwan.cn/',
    'sec-ch-ua: "Microsoft Edge";v="137", "Chromium";v="137", "Not/A)Brand";v="24"',
    'sec-ch-ua-mobile: ?0',
    'sec-ch-ua-platform: "Windows"',
    'sec-fetch-dest: document',
    'sec-fetch-mode: navigate',
    'sec-fetch-site: cross-site',
    'sec-fetch-user: ?1',
    'upgrade-insecure-requests: 1',
    'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0',
]);
curl_setopt($ch, CURLOPT_COOKIE, 'x-hng=lang=zh-CN&domain=s0.wp.com');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpCode == 307) {
    readfile($save_path. 'nopic.jpg'); exit;
}
file_put_contents($save_path . md5($site) . '.gif', $response);
echo $response;
?>